#include <iostream>
using namespace std;

/*
	受到cout输出的原理启发，我想直接打印(输出)结构体，自定义的类对象(猫)
	受到cin输入的原理启发，我想直接读取键盘输入的数据存放到自定义的类对象(猫)
*/

class Cat
{
public:
	friend ostream &operator<<(ostream &out,Cat &other); //可以连续打印
	friend istream &operator>>(istream &in,Cat &other);
private:
	int age;
	string name;
	float weight;
};

ostream &operator<<(ostream &out,Cat &other) //可以连续打印
{
	cout<<"友元函数输出被调用"<<endl;
	out<<other.name<<endl;
	out<<other.weight<<endl;
	out<<other.age<<endl;
	return out;
}

istream &operator>>(istream &in,Cat &other) //可以连续输入
{
	cout<<"友元函数输入被调用"<<endl;
	in>>other.name;
	in>>other.weight;
	in>>other.age;
	return in;
}

int main()
{
	Cat c1;
	Cat c2;
	cout<<"请依次输入猫的姓名，体重，年龄"<<endl;
	/*
		人类的思维习惯
		   cin>>c1;
		函数调用
		   cin.operator>>(c1)   //成员函数，不正确，istream这个类里面根本就没有这个版本
		   operator>>(cin,c1)   //友元函数，正确

	*/
	cin>>c1;
	cin>>c2;
	//或者
	//cin>>c1>>c2;
	cout<<c1<<c2;
	

	
}